<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	request.setCharacterEncoding("UTF-8");
	String htmlData = request.getParameter("content1") != null ? request.getParameter("content1") : "";
%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dth">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<script type="text/javascript"
	src="<%=path%>/My97DatePicker/WdatePicker.js"></script>
<link rel="stylesheet" type="text/css"
	href="<%=path%>/CSS/backLayout.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/CSS/bombBox.css">
</head>
<style>
.gn_name {
	padding-top: 8px
}

input[type=checkbox] {
	width: 15px
}
.div_input {
	width: 500px;
	height: 40px;
}
</style>
<body style="background: #f5f5f5">
	<div class="main">
		<div id="modal-overlay"></div>
		<div class="modal-data2">
			<div style="height: 60px">
				<ul>
					<li
						style="text-align: left; margin-left: 60px; height: 40px; line-height: 40px">
						<span>名称：</span> <span> <input class="name" type="text">
					</span> <span>
							<button class="findBtn">查询</button>
					</span>
					</li>
				</ul>
			</div>
			<div style="width: 100%; height: 350px; overflow: scroll;">
				<form action="">
					<table class="head2"
						style="width: auto; white-space: nowrap; border-spacing: 0px">
						<tr style="background: #f2f2f2; height: 30px; line-height: 20px;"
							class="sel">
							<td style="width: 20px"></td>
							<td>员工编号</td>
							<td>员工姓名</td>
							<td>部门</td>
							<td>员工类型</td>
							<td>身份证号码</td>
							<td>手机号码</td>
							<td>地址</td>
							<td>出生日期</td>
							<td>入职日期</td>
							<td>转正日期</td>
							<td>离职日期</td>
							<td>合同到期日</td>
							<td>社保编号</td>
							<td>车辆</td>
							<td>性别</td>
							<td>职级职等</td>
							<td>薪酬调整</td>
							<td>岗位异动</td>
							<td>请假记录</td>
							<td>违纪奖励记录</td>
							<td>社会保险记录</td>
							<td>计算招生提成</td>
							<td>计算培训提成</td>
						</tr>
						<c:forEach items="${persons}" var="persons" varStatus="s">
							<tr style="margin-top: 45px" class="jx">
								<td><input type="checkbox" class="check"
									value="${persons.fid}" name="train" /></td>
								<td>${persons.fnumber}</td>
								<td>${persons.fnameL2}</td>
								<td>${persons.cfpersondepName}</td>
								<c:if test="${empty persons.cfpersontype}">
									<td></td>
								</c:if>
								<c:if test="${persons.cfpersontype == '0'}">
									<td></td>
								</c:if>
								<c:if test="${persons.cfpersontype == '1'}">
									<td>办公室职员</td>
								</c:if>
								<c:if test="${persons.cfpersontype == '2'}">
									<td>教练</td>
								</c:if>
								<c:if test="${persons.cfpersontype == '3'}">
									<td>其他</td>
								</c:if>
								<td>${persons.cfidcardno}</td>
								<td>${persons.cfcell}</td>
								<td>${persons.cfaddress}</td>
								<td>${persons.cfbirthdays}</td>
								<td>${persons.cfbegindate}</td>
								<td>${persons.cfstartdate}</td>
								<td>${persons.cfenddate}</td>
								<td>${persons.cfhtdqsj}</td>
								<td>${persons.cfaccountsno}</td>
								<td>${persons.cfcarName}</td>
								<c:if test="${empty persons.cfsex}">
									<td></td>
								</c:if>
								<c:if test="${persons.cfsex == '1'}">
									<td>男</td>
								</c:if>
								<c:if test="${persons.cfsex == '2'}">
									<td>女</td>
								</c:if>
								<td>${persons.positiongradeName}</td>
								<td>${persons.cfxctz}</td>
								<td>${persons.cfgwyd}</td>
								<td>${persons.cfqjjl}</td>
								<td>${persons.cfwjjljl}</td>
								<td>${persons.cfshjljl}</td>
								<c:if test="${empty persons.cfzstc}">
									<td><input type="checkbox" disabled="disabled"></td>
								</c:if>
								<c:if test="${persons.cfzstc == '0'}">
									<td><input type="checkbox" disabled="disabled"></td>
								</c:if>
								<c:if test="${persons.cfzstc == '1'}">
									<td><input type="checkbox" disabled="disabled"
										checked="checked"></td>
								</c:if>
								<c:if test="${empty persons.cfpxtc}">
									<td><input type="checkbox" disabled="disabled"></td>
								</c:if>
								<c:if test="${persons.cfpxtc == '0'}">
									<td><input type="checkbox" disabled="disabled"></td>
								</c:if>
								<c:if test="${persons.cfpxtc == '1'}">
									<td><input type="checkbox" disabled="disabled"
										checked="checked"></td>
								</c:if>
							</tr>
						</c:forEach>
					</table>
				</form>
			</div>
			<button class="subtn2"
				style="width: 200px; position: absolute; bottom: 25px; font-size: 16px; left: 170px">
				确定</button>
			<button class="btn"
				style="width: 200px; position: absolute; bottom: 25px; font-size: 16px; right: 170px">
				关闭</button>
		</div>
		<c:if test="${empty team}">
		<div class="weizhi">职员基础资料>>教练队>>新增</div>
		</c:if>
		<c:if test="${not empty team}">
		<div class="weizhi">职员基础资料>>教练队>>修改</div>
		</c:if>
		<div class="div_body" style="box-shadow: 0 0 5px #cccccc;">
			<div class="div_form">
			<c:if test="${empty team}">
				<form action="<%=path%>/DrivingSys/addTeam" class="form" onsubmit="return submit2();" method="post">
						<div class="fwrz">
							<div class="div_input">
								<span class="gn_name">驾校&nbsp;:&nbsp;</span> <input type="text"
									readonly="readonly" value="${department.fnameL2}"
									style="color: gray;">
							</div>
							<div class="div_input">
								<span class="gn_name">编码&nbsp;:&nbsp;</span> <input type="text"
									name="fnumber" value="${fnumber}" readonly="readonly"
									style="color: gray;">
							</div>
							<div class="div_input">
								<span class="gn_name">名称&nbsp;:&nbsp;</span> <input type="text"
									name="fnameL2" class="name2">
								<span class="required">必填</span>
							</div>
							<div class="div_input">
								<span class="gn_name">简称&nbsp;:&nbsp;</span> <input type="text"
									name="fsimplename">
							</div>
							<div class="div_input">
								<span class="gn_name">描述&nbsp;:&nbsp;</span> <input type="text"
									name="fdescriptionL2">
							</div>
							<div class="div_input">
								<span class="gn_name">科目&nbsp;:&nbsp;</span> <select
									name="cfkemu" style="width: 234px; height: 31px">
									<option value="1">科目一</option>
									<option value="2">科目二</option>
									<option value="3">科目三</option>
								</select>
							</div>
							<div class="div_input">
								<span class="gn_name">队长&nbsp;:&nbsp;</span> <input type="text"
																					class="teamName is_click_ne"
																					id="teamName2"> <input type="hidden"
																										   name="cfduizhangid" id="teamName">
							</div>
						</div>
					<div class="div_tj" style="margin-left: 140px">
						<div>
							<input type="submit" class="input_submit bc" value="" style="margin-right: 30px;"/>
						</div>
						<div>
							<input type="button" class="input_back fh" value=""
								   onclick="back()"/>
						</div>
					</div>
				</form>
			</c:if>
			<c:if test="${not empty team}">
				<form action="<%=path%>/DrivingSys/modifyTeam" class="form" onsubmit="return submit2();" method="post">
						<div class="fwrz">
							<div class="div_input">
								<span class="gn_name">驾校&nbsp;:&nbsp;</span> <input type="text"
									readonly="readonly" value="${department.fnameL2}"
									style="color: gray;">
							</div>
							<div class="div_input">
								<span class="gn_name">编码&nbsp;:&nbsp;</span> <input type="text"
									name="fnumber" value="${team.fnumber}" readonly="readonly"
									style="color: gray;">
									<input type="hidden" name="fid" value="${team.fid}">
							</div>
							<div class="div_input">
								<span class="gn_name">名称&nbsp;:&nbsp;</span> <input type="text"
									name="fnameL2" value="${team.fnameL2}" class="name2">
								<span class="required">必填</span>
							</div>
							<div class="div_input">
								<span class="gn_name">简称&nbsp;:&nbsp;</span> <input type="text"
									name="fsimplename" value="${team.fsimplename}">
							</div>
							<div class="div_input">
								<span class="gn_name">描述&nbsp;:&nbsp;</span> <input type="text"
									name="fdescriptionL2" value="${team.fdescriptionL2}">
							</div>
							<div class="div_input">
								<span class="gn_name">科目&nbsp;:&nbsp;</span> <select
									name="cfkemu" style="width: 234px; height: 31px">
									<c:if test="${team.cfkemu == '1'}">
										<option value="1">科目一</option>
										<option value="2">科目二</option>
										<option value="3">科目三</option>
									</c:if>
									<c:if test="${team.cfkemu == '2'}">
										<option value="2">科目二</option>
										<option value="1">科目一</option>
										<option value="3">科目三</option>
									</c:if>
									<c:if test="${team.cfkemu == '3'}">
										<option value="3">科目三</option>
										<option value="2">科目二</option>
										<option value="1">科目一</option>
									</c:if>
								</select>
							</div>
							<div class="div_input">
								<span class="gn_name">队长&nbsp;:&nbsp;</span> <input type="text"
																					class="teamName is_click_ne"
																					id="teamName2"
																					value="${team.teamName}"> <input
									type="hidden"
									name="cfduizhangid" id="teamName">
							</div>
						</div>
					<div class="div_tj" style="margin-left: 140px">
						<div>
							<input type="submit" class="input_submit bc" value="" style="margin-right: 30px;"/>
						</div>
						<div>
							<input type="button" class="input_back fh" value=""
								   onclick="back()"/>
						</div>
					</div>
				</form>
			</c:if>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript" src="<%=path%>/JQuery/jquery-1.8.2.js"></script>
<%@ include file="/WEB-INF/JSP/ajax.jsp"%>
<script type="text/javascript">

$(document).ready(function(){
	var type = "${type}"
	if(type == null || type == ''){
		
	}else{
        editAlert();
	}
})

//   显示职员信息
$('#teamName2').click(function(){
	$('#modal-overlay').css('visibility','visible')
	$('.modal-data2').css('visibility','visible')
	$('input:checkbox').removeAttr('checked');
})

function submit2(){
	var name = $(".name2").val();
	if(name == null || name == ''){
		alert("名称不能未空")
		return false
	}
    //提交后把提交变成不可用，可阻止表单重复提交
    $("input[type='submit']").attr("disabled", "disabled");
}

//取消
$('.btn').click(function(){
		$('#modal-overlay').css('visibility','hidden')
		$('.modal-data2').css('visibility','hidden')
		$('input:checkbox').removeAttr('checked');
})

//根据名称查询
$(".findBtn").click(function(){
	var name = $(".name").val();
	$.ajax({
		url:'<%=path%>/DrivingSys/quePersonByName', 
	    type: "post",
	    data:{'name':name},
	    dataType:"json",
	    success:function(json){
	    	var str=''
	    	for(var i = 0;i < json.length;i++){
	    		 str+='<tr style="margin-top: 45px;height: 30px;" class="jx"><td><input style="width: 15px;height: 15px" '
	  	         str+='type="checkbox" name="train"  value="'+json[i].fid+'"></td>'
			    	 if(json[i].fnumber == null ){
			    		str+='<td></td>'	
			    	 }else{
			    		str+='<td>'+json[i].fnumber+'</td>'
			    	 }
		    		 if(json[i].fnameL2 == null ){
				    		str+='<td></td>'	
				    }else{
				    		str+='<td>'+json[i].fnameL2+'</td>'
				    }
		    		if(json[i].cfpersondepName == null ){
				    		str+='<td></td>'	
				    }else{
				    		str+='<td>'+json[i].cfpersondepName+'</td>'
				    }
			   		if(json[i].cfpersontype == '1'){
			   			str+='<td>办公室职员</td>'
			   		}
			   		else if(json[i].cfpersontype == '2'){
			   			str+='<td>教练</td>'
			   	    }else if(json[i].cfpersontype == '3'){
			   			str+='<td>其他</td>'
			   		}else{
			   			str+='<td></td>'
			   		}
			   		if(json[i].cfidcardno == null ){
			    		str+='<td></td>'	
			    	}else{
			    		str+='<td>'+json[i].cfidcardno+'</td>'
			   		}
			   		if(json[i].cfcell == null ){
			    		str+='<td></td>'	
			    	}else{
			    		str+='<td>'+json[i].cfcell+'</td>'
			   		}
			   		if(json[i].cfaddress == null ){
			    		str+='<td></td>'	
			    	}else{
			    		str+='<td>'+json[i].cfaddress+'</td>'
			   		}
			   		if(json[i].cfbirthdays == null ){
			    		str+='<td></td>'	
			    	}else{
			    		str+='<td>'+json[i].cfbirthdays+'</td>'
			   		}
			   		if(json[i].cfbegindate == null ){
			    		str+='<td></td>'	
			    	}else{
			    		str+='<td>'+json[i].cfbegindate+'</td>'
			   		}
			   		if(json[i].cfstartdate == null ){
			    		str+='<td></td>'	
			    	}else{
			    		str+='<td>'+json[i].cfstartdate+'</td>'
			   		}
			   		if(json[i].cfenddate == null ){
			    		str+='<td></td>'	
			    	}else{
			    		str+='<td>'+json[i].cfenddate+'</td>'
			   		}
			   		if(json[i].cfhtdqsj == null ){
			    		str+='<td></td>'	
			    	}else{
			    		str+='<td>'+json[i].cfhtdqsj+'</td>'
			   		}
			   		if(json[i].cfhtdqsj == null ){
			    		str+='<td></td>'	
			    	}else{
			    		str+='<td>'+json[i].cfaccountsno+'</td>'
			   		}
			   		if(json[i].cfcarName == null ){
			    		str+='<td></td>'	
			    	}else{
			    		str+='<td>'+json[i].cfcarName+'</td>'
			   		}
			   		if(json[i].cfsex == '1' ){
			    		str+='<td>男</td>'	
			    	}else if(json[i].cfsex == '2'){
			    		str+='<td>女</td>'
			   		}else{
			   			str+='<td></td>'
			   		}
			   		if(json[i].positiongradeName == null ){
			    		str+='<td></td>'	
			    	}else{
			    		str+='<td>'+json[i].positiongradeName+'</td>'
			   		}
			   		if(json[i].cfxctz == null ){
			    		str+='<td></td>'	
			    	}else{
			    		str+='<td>'+json[i].cfxctz+'</td>'
			   		}
			   		if(json[i].cfgwyd == null ){
			    		str+='<td></td>'	
			    	}else{
			    		str+='<td>'+json[i].cfgwyd+'</td>'
			   		}
			   		if(json[i].cfqjjl == null ){
			    		str+='<td></td>'	
			    	}else{
			    		str+='<td>'+json[i].cfqjjl+'</td>'
			   		}
			   		if(json[i].cfwjjljl == null ){
			    		str+='<td></td>'	
			    	}else{
			    		str+='<td>'+json[i].cfwjjljl+'</td>'
			   		}
			   		if(json[i].cfshjljl == null ){
			    		str+='<td></td>'	
			    	}else{
			    		str+='<td>'+json[i].cfshjljl+'</td>'
			   		}
			   		if(json[i].cfzstc == '0'){
			   			str+='<td><input type="checkbox" disabled="disabled"></td>'
			   		}
			   		else if(json[i].cfzstc == '1'){
			   			str+='<td><input type="checkbox" disabled="disabled" checked="checked"></td>'
			   		}else{
			   			str+='<td><input type="checkbox" disabled="disabled"></td>'
			   		}
			   		if(json[i].cfpxtc == '1'){
			   			str+='<td><input type="checkbox" disabled="disabled" checked="checked"></td>'
			   		}else{
			   			str+='<td><input type="checkbox" disabled="disabled"></td>'
		    		}
			   	 str+='</tr>';
	    		}
	    	 	$(".head2 tr:not(':first')").remove()
	            $('.head2').append(str)
	    	},  
			error: function(){alert('Error');} 
		})
	})
//选择数据
$(".subtn2").click(function(){
	var fid = "";
		$('input:checkbox:checked').each(function(i){
		    if(0==i){
		    	   fid = $(this).val();
		    }
	      });  	
	      if(fid==""){
	    	  alert("请选择一条数据")
	    	  return false
	      }else{
			  $.ajax({
				url:'<%=path%>/DrivingSys/quePersonByFid',
				type : "post",
				data : {'fid' : fid},
				dataType : "json",
				success : function(json) {
					$("#teamName2").val(json.fnameL2)
					$("#teamName").val(fid)
				},
				error : function() {
					alert('Error');
				}
			})
			
		}
		$('#modal-overlay').css('visibility', 'hidden')
		$('.modal-data2').css('visibility', 'hidden')
	});

//双击确定
$(document).on('dblclick','.jx td',function(){
	     var fid = $(this).parent().find("input[name=train]").val();
		 $.ajax({
			url:'<%=path%>/DrivingSys/quePersonByFid',
			type : "post",
			data : {'fid' : fid},
			dataType : "json",
			success : function(json) {
				$("#teamName2").val(json.fnameL2)
				$("#teamName").val(fid)
			},
			error : function() {
				alert('Error');
			}
		})
	$('#modal-overlay').css('visibility', 'hidden')
	$('.modal-data2').css('visibility', 'hidden')
})

//单击选中
$(".jx td").live('click',function(){
    $('input:checkbox[name=train]:checked').each(function(i) {
    	$(this).removeAttr("checked");
     });
     $(this).parent().find("input:checkbox").attr('checked','checked');
}) 

function back(){
	location = '<%=path%>/DrivingSys/queryTeam/look.action';
}
</script>
</html>